package sunbao.ido.controller;

import com.alipay.jarslink.api.Module;
import com.alipay.jarslink.api.ModuleConfig;
import com.alipay.jarslink.api.ModuleLoader;
import com.alipay.jarslink.api.ModuleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import sunbao.ido.config.ConfigChangedEvent;
import sunbao.ido.config.ConfigClient;
import sunbao.ido.config.ModuleRefreshSchedulerImpl;
import sunbao.ido.service.IDoLaService;
import sunbao.ido.service.IDoService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;


/**
 * \* User: MeiZhongHao
 * \* Date: 2018-10-22
 * \* Time: 16:33
 * \* Description:
 * \
 */
@RestController
public class Controller {

    @Resource
    IDoService iDoService;

    @Resource
    IDoLaService iDoLaService;

    @Value("${name}")
    private String name;

    @Autowired
    private ModuleLoader moduleLoader;

    @Autowired
    private Module xiaomiModel;

    @GetMapping(value = "/hello")
    public String say() {
        return iDoService.doPrint();
    }

    @GetMapping(value = "/la")
    public String la() {
        return iDoLaService.la();
    }

    @GetMapping(value = "/name")
    public String name() {
        return name;
    }

    @GetMapping(value = "/reflushProperties")
    public String reflushProperties() {
        ConfigClient.init();
        ConfigClient.notifyListeners(new ConfigChangedEvent(this));
        return "刷新成功";
    }

    @GetMapping("/jarsLink")
    public String test() {
        String result = xiaomiModel.doAction("jarsLink", "");
        return result;
    }

}